#include<stdio.h>

int main()
{
    printf("123153452\n");
    printf("123154352\n");
    printf("123451352\n");
    printf("123453152\n");
    printf("123513452\n");
    printf("123543152\n");
    printf("125134532\n");
    printf("125135432\n");
    printf("125315432\n");
    printf("125345132\n");
    printf("125431532\n");
    printf("125435132\n");
    printf("132153452\n");
    printf("132154352\n");
    printf("132534512\n");
    printf("132543512\n");
    printf("134512352\n");
    printf("134512532\n");
    printf("134521532\n");
    printf("134523512\n");
    printf("134532152\n");
    printf("134532512\n");
    printf("135123452\n");
    printf("135125432\n");
    printf("135215432\n");
    printf("135234512\n");
    printf("135432152\n");
    printf("135432512\n");
    printf("152134532\n");
    printf("152135432\n");
    printf("152345312\n");
    printf("152354312\n");
    printf("153123452\n");
    printf("153125432\n");
    printf("153213452\n");
    printf("153254312\n");
    printf("153452132\n");
    printf("153452312\n");
    printf("154312352\n");
    printf("154312532\n");
    printf("154321352\n");
    printf("154325312\n");
    printf("154352132\n");
    printf("154352312\n");
    return 0;
}
